import axios from 'axios'

// 登录方法
export function login(userName, password) {
    const data = {
      userName,
      password
    }
    return request({
      url: '/user/login',
      headers: {
        isToken: true,
        repeatSubmit: false,
        'Content-Type': 'application/json'
      },
      method: 'post',
      data: data
    }).then(response => {
      console.log('登录返回数据：', response)
      return response
    })
  }
  // 注册方法
export function register(data) {
    return request({
      url: '/user/register',
      headers: {
        isToken: false
      },
      method: 'post',
      data: data
    })
  }

export function testLogin(userName, password) {
  return axios({
    url: 'http://localhost:8081/user/login',
    method: 'post',
    data: {
      userName,
      password
    },
    headers: {
      'Content-Type': 'application/json'
    }
  }).then(response => {
    console.log('直接请求测试：', response);
  }).catch(error => {
    console.log('直接请求错误：', error);
  });
}